#include "header.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>



//输入球队信息选项
void menu1(team t[DATE],int n)
{
	system("CLS");
	printf("\n\n\t\t请输入球队名称:");scanf("%s",&t[n].Name);
	printf("\n\t\t请输入球队成立时间:");scanf("%s",&t[n].EstablishmentTime);
	printf("\n\t\t请输入球队主场:");scanf("%s",&t[n].HomeCourt);
	printf("\n\t\t请输入球队历史荣誉:");scanf("%s",&t[n].Honor);
	printf("\n\t\t请输入球队人数:");scanf("%d",&t[n].NumPeople);
	system("pause");
	return;
}

//输入球员信息选项
int menu2(player p[DATE],int num,int i)
{
	printf("\n\n\t\t请输入球员人数:");scanf("%d",&num);
	system("CLS");
	for(i = 0;i < num;i++)
	{
		printf("\n\t\t请输入第%d位球员姓名:",i+1);
		scanf("%s",&p[i].Name);
		printf("\n\t\t请输入第%d位球员年龄:",i+1);
		scanf("%d",&p[i].Age);
		printf("\n\t\t请输入第%d位球员身高:",i+1);
		scanf("%d",&p[i].Height);
		printf("\n\t\t请输入第%d位球员体重:",i+1);
		scanf("%d",&p[i].Weight);
		printf("\n\t\t请输入第%d位球员球衣号码:",i+1);
		scanf("%d",&p[i].Number);
		fflush(stdin);
		printf("\n\t\t请输入第%d位球员司职:",i+1);
		gets(p[i].Position);
		fflush(stdin);
		printf("\n\t\t请输入第%d位球员薪水:",i+1);
		scanf("%d",&p[i].Salary);
		fflush(stdin);
		printf("\n\t\t请输入第%d位球员出生日期:",i+1);
		gets(p[i].BirthDate);
	    fflush(stdin);
	    system("CLS");
	}
	system("pause");
	return num;
}

//输入比赛信息选项
void menu3(competition c[DATE],int n)
{   
    system("CLS");
	printf("\n\n\t\t请输入比赛名称:");scanf("%s",&c[n].Name);
	printf("\n\t\t请输入主场队伍名称:");scanf("%s",&c[n].HomeT);
	printf("\n\t\t请输入客场队伍名称:");scanf("%s",&c[n].VisitT);
	printf("\n\t\t请输入比赛日期:");scanf("%s",&c[n].Date);
	printf("\n\t\t请输入主场队伍进球数:");scanf("%d",&c[n].HomeTGoal);
	printf("\n\t\t请输入客场队伍进球数:");scanf("%d",&c[n].VisitTGoal);
	system("pause");
	return;
}

//输入球员比赛数据选项
void menu4(playerDate pd[DATE],player p[DATE],int n,int i)
{
	system("CLS");
	for(i = 0;i < n;i++)
	{
		strcpy(pd[i].Name,p[i].Name);
		strcpy(pd[i].Position,p[i].Position);
	    pd[i].Number = p[i].Number;
    	printf("\n\t\t请输入%d号球员进球数:",p[i].Number);scanf("%d",&pd[i].Goal);
    	printf("\n\t\t请输入%d号球员总传球数:",p[i].Number);scanf("%d",&pd[i].Allpass);
    	for(;;)
        {
            printf("\n\t\t请输入%d号球员成功传球数:",p[i].Number);scanf("%d",&pd[i].Successpass);
            if(pd[i].Successpass > pd[i].Allpass)
        {
        	system("CLS");
	        printf("\n\n\t\t成功传球数输入错误!\n\t\t请重新输入!");
	        system("pause");
	        system("CLS");
        }
        else
		{
	        break;
	    }
        }
    	printf("\n\t\t请输入%d号球员犯规数:",p[i].Number);scanf("%d",&pd[i].Foul);
    	printf("\n\t\t请输入%d号球员黄牌数:",p[i].Number);scanf("%d",&pd[i].YellowC);
    	printf("\n\t\t请输入%d号球员红牌数:",p[i].Number);scanf("%d",&pd[i].RedC);
    	printf("\n\t\t请输入%d号球员扑球数:",p[i].Number);scanf("%d",&pd[i].NumSaveball);
    	for(;;)
        {
           	printf("\n\t\t请输入%d号球员成功扑球数:",p[i].Number);scanf("%d",&pd[i].NumSuccessSaveball);
            if(pd[i].NumSuccessSaveball > pd[i].NumSaveball)
            {
            	system("CLS");
	            printf("\n\n\t\t成功扑球数输入错误!\n\t\t请重新入!");
	            system("pause");
	            system("CLS");
            }
            else
			{
	            break;
	        }
        }
		system("CLS");                       
	}
	return;
}


//查询球队信息选项
void show1(team t[DATE],int n)
{
	system("CLS");
	printf("\n\n\t\t球队信息如下:");
	printf("\n\n\t\t球队名称:%s",t[n].Name);
	printf("\n\t\t球队建立时间:%s",t[n].EstablishmentTime);
	printf("\n\t\t球队主场:%s",t[n].HomeCourt);
	printf("\n\t\t球队历史荣誉:%s",t[n].Honor);
	printf("\n\t\t球队人数:%d",t[n].NumPeople);
	printf("\n\n");
	system("pause");
	return;
}

//查询球员信息选项
void show2(player p[DATE],int n,int i)
{
	system("CLS");
	printf("\n\n\t\t球员信息如下:");
	printf("\n\n\t\t球员人数为:%d",n);
	for(i = 0;i < n;i++)
	{
		printf("\n\n\t\t球员姓名:%s",p[i].Name);
	    printf("\n\t\t球员年龄:%d岁",p[i].Age);
    	printf("\n\t\t球员身高:%dcm",p[i].Height);
    	printf("\n\t\t球员体重:%dkg",p[i].Weight);
    	printf("\n\t\t球员球衣号码:%d",p[i].Number);
    	printf("\n\t\t球员司职:%s",p[i].Position);
     	printf("\n\t\t球员薪水:%d",p[i].Salary);
    	printf("\n\t\t球员生日:%s",p[i].BirthDate);
    	printf("\n");
	}
	system("pause");
	return;
}

//查询比赛信息选项
void show3(competition c[DATE],int n)
{
	system("CLS");
	printf("\n\n\t\t比赛信息如下:");
	printf("\n\t\t比赛名称:%s",c[n].Name);
	printf("\n\t\t比赛主场队伍:%s",c[n].HomeT);
	printf("\n\t\t比赛客场队伍:%s",c[n].VisitT);
	printf("\n\t\t比赛日期:%s",c[n].Date);
	printf("\n\t\t比赛主场队伍分数:%d",c[n].HomeTGoal);
	printf("\n\t\t比赛客场队伍分数:%d",c[n].VisitTGoal);
	printf("\n\n");
	system("pause");
	return;
}

//查询球员比赛数据信息选项
void show4(playerDate pd[DATE],int n,int i)
{
	int number;
	system("CLS");
	printf("\n\n\t\t请输入需要查询的球员球衣号码:");
	scanf("%d",&number);
	for(i = 0;i < n;i++)
	{
		if(pd[i].Number == number)
		{
			printf("\n\n\t\t该球员比赛数据信息如下:");
	        printf("\n\t\t球员姓名:%s",pd[i].Name);
         	printf("\n\t\t球员球衣号码:%d",pd[i].Number);
         	printf("\n\t\t球员司职:%s",pd[i].Position);
         	printf("\n\t\t球员比赛进球数:%d",pd[i].Goal);
          	printf("\n\t\t球员总传球数:%d",pd[i].Allpass);
          	printf("\n\t\t球员成功传球数:%d",pd[i].Successpass);
          	printf("\n\t\t球员犯规数:%d",pd[i].Foul);
        	printf("\n\t\t球员黄牌数:%d",pd[i].YellowC);
         	printf("\n\t\t球员红牌数:%d",pd[i].RedC);
         	printf("\n\t\t球员总扑球数:%d",pd[i].NumSaveball);
         	printf("\n\t\t球员成功扑球数:%d",pd[i].NumSuccessSaveball);
        	system("pause");
		}
	}
	return;
}

//增删球员选项
int add_cut(player p[DATE],int n,int i)
{
	while(1)
	{
		system("CLS");
	    printf("\n\n\t\t1.增加球员");
	    printf("\n\t\t2.删减球员");
        printf("\n\t\t0.退出");
	    int option;
	    printf("\n\t\t请输入选项:");
	    scanf("%d",&option);

		switch(option)
		{
			case 0:
			{
				return n;
			}
			case 1:
			{
				int addnum;
        	    system("CLS");
        	    printf("\n\n\t\t输入需要增加球员数量:");
            	scanf("%d",&addnum);
        	    system("CLS");
	        for(i = n;i < n+addnum;i++)
         	{
	        	printf("\n\n\t\t输入第%d位球员信息:",i+1);
	        	printf("\n\t\t姓名:");
	        	scanf("%s",&p[i].Name);
	        	printf("\n\t\t年龄:");
	        	scanf("%d",&p[i].Age);
	        	printf("\n\t\t身高:");
		        scanf("%d",&p[i].Height);
	        	printf("\n\t\t体重:");
	        	scanf("%d",&p[i].Weight);
	        	printf("\n\t\t球衣号码:");
	        	scanf("%d",&p[i].Number);
	        	printf("\n\t\t司职:");
	        	scanf("%s",&p[i].Position);
	        	printf("\n\t\t薪水:");
	        	scanf("%d",&p[i].Salary);
	        	printf("\n\t\t出生日期:");
	        	scanf("%s",&p[i].BirthDate);
		        system("pause");
	        }
        	n = n + addnum;

				break;
			}
			case 2:
			{
				
			while(1)
	        {
		    system("CLS");
         	printf("\n\n\t\t查询并删除球员:");
         	printf("\n\t\t1.输入球衣号码查询并删除:");
        	printf("\n\t\t2.输入姓名查询并删除:");
         	printf("\n\t\t0.退出");
        	int option;
           	printf("\n\t\t请输入选项:");
           	scanf("%d",&option);
    
	    	switch(option)
	    	{
		    	case 0:
			    {
				    return n;
			    }
		        case 1:
		        {
		    	
		        	int number;
                	system("CLS");
                	printf("\n\n\t\t输入球员球衣号码:");
                	scanf("%d",&number);
	                system("CLS");
	                for(i = 0;i < n;i++)
              	    {
		            if(p[i].Number==number)
		            {
	                printf("\n\n\t\t球员姓名:%s",p[i].Name);
	                printf("\n\t\t球员年龄:%d岁",p[i].Age);
                 	printf("\n\t\t球员身高:%dcm",p[i].Height);
                  	printf("\n\t\t球员体重:%dkg",p[i].Weight);
    	            printf("\n\t\t球员球衣号码:%d",p[i].Number);
                   	printf("\n\t\t球员司职:%s",p[i].Position);
     	            printf("\n\t\t球员薪水:%d",p[i].Salary);
                 	printf("\n\t\t球员生日:%s",p[i].BirthDate);
    	            printf("\n");
                  	printf("\n\t\t是否确定删除该球员?");
                    printf("\n\n\t\t1.确定删除该球员");
        
                    while(1)
	                {
                    printf("\n\n\t\t0.退出");
                    int option;
                    printf("\n\n\t\t请输入选项:");
                    scanf("%d",&option);
                    switch(option)
                    {
    	            case 0:
    	            {
    		            return n;
		            }
		            case 1:
		            {
			            for(;i < n;i++)
    	                {
    		                p[i] = p[i+1];
		                }
		                system("CLS");
		                printf("\n\n\t\t已成功删除该球员！");
		                n = n - 1;
		                printf("\n\t\t当前球员人数:%d",n);
		            	break;
		            }
		            default: continue;
	                }
                    }
    	            break;
	               	}
	                }
		    	    break;
			    }
			    case 2:
			    {
				    char name[20];
	                system("CLS");
	                printf("\n\n\t\t输入球员姓名:");
	                scanf("%s",&name);
	                system("CLS");
	                for(i = 0;i < n;i++)
	                {
		                if(strcmp(p[i].Name,name)==0)
		                {
	                        printf("\n\n\t\t球员姓名:%s",p[i].Name);
	                        printf("\n\t\t球员年龄:%d岁",p[i].Age);
    	                    printf("\n\t\t球员身高:%dcm",p[i].Height);
                           	printf("\n\t\t球员体重:%dkg",p[i].Weight);
                         	printf("\n\t\t球员球衣号码:%d",p[i].Number);
                           	printf("\n\t\t球员司职:%s",p[i].Position);
                           	printf("\n\t\t球员薪水:%d",p[i].Salary);
                          	printf("\n\t\t球员生日:%s",p[i].BirthDate);
                          	printf("\n");
                         	printf("\n\t\t是否确定删除该球员?");
                            printf("\n\n\t\t1.确定删除该球员"); 
        
                            while(1)
                           	{
                                printf("\n\n\t\t0.退出");
                                int option;
                                printf("\n\t\t请输入选项:");
                                scanf("%d",&option);
                                switch(option)
                                {
    	                            case 0:
    	                            {
    		                            return n;
		                            }
		                            case 1:
		                            {
			                            for(;i < n;i++)
    	                                {
    	    	
    		                                p[i] = p[i+1];
		                                }
		                                printf("\n\n\t\t已成功删除该球员！");
		                                n = n - 1;
		                                printf("\n\t\t当前球员人数:%d",n);
			                            break;
		                            }
		                            default: continue;
	                            }
                            }
        
        
	                     	break;
		                }
	                }
			    	break;
			    }    
			default: continue;
		    }
	        }
				break;
			}
			default: continue;
		}
	}
	return n;
}

//更改球队信息选项
void change_t(team t[DATE],int n)
{
	while(1)
	{
	printf("\n\n\t\t0.退出");
	printf("\n\n\t\t请输入选项:");
	int option;
	scanf("%d",&option);
	switch(option)
	{
	case 0:
	{
		return;
	}
	case 1:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的球队名称:");
		scanf("%s",&t[n].Name);		
		printf("\n\n\t\t更改完成!");
		break;
	}
	case 2:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的球队成立时间:");
		scanf("%s",&t[n].EstablishmentTime);
		printf("\n\n\t\t更改完成!");
		break;
	}
	case 3:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的球队主场:");
		scanf("%s",&t[n].HomeCourt);
		printf("\n\n\t\t更改完成!");
		break;
	}
	case 4:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的球队荣誉:");
		scanf("%s",&t[n].Honor);
		printf("\n\n\t\t更改完成!");
		break;
	}
	case 5:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的人数:");
		scanf("%d",&t[n].NumPeople);
		printf("\n\n\t\t更改完成!");
	}
	default: continue;
    }
    }
    return;
}

//更改比赛信息选项
void change_tm(competition c[DATE],int n)
{
	while(1)
	{
	printf("\n\n\t\t0.退出");
	printf("\n\n\t\t请输入选项:");
	int option;
	scanf("%d",&option);
	switch(option)
	{
	case 0:
	{
		return;
	}
	case 1:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的比赛名称:");
		scanf("%s",&c[n].Name);		
		printf("\n\n\t\t更改完成!");
		break;
	}
	case 2:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的主场队伍:");
		scanf("%s",&c[n].HomeT);
		printf("\n\n\t\t更改完成!");
		break;
	}
	case 3:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的客场队伍:");
		scanf("%s",&c[n].VisitT);
		printf("\n\n\t\t更改完成!");
		break;
	}
	case 4:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后比赛日期:");
		scanf("%s",&c[n].Date);
		printf("\n\n\t\t更改完成!");
		break;
	}
	case 5:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的主队进球数:");
		scanf("%d",&c[n].HomeTGoal);
		printf("\n\n\t\t更改完成!");
		break;
	}
	case 6:
	{
		system("CLS");
		printf("\n\n\t\t请输入更改后的客队进球数:");
		scanf("%d",&c[n].VisitTGoal);
		printf("\n\n\t\t更改完成!");
		break;
	}
	default: continue;
    }
    }
    return;
}
//更改球员比赛信息选项
void change_playerDate(playerDate pd[DATE],int n,int i,int number)
{
    for(i = 0;i < n;i++)
    {
    	if(pd[i].Number == number)
    	{
    		
    		while(1)
    		{
    			int option;
    			printf("\n\t\t0.退出");
    		    printf("\n\t\t请输入选项:");
    		    scanf("%d",&option);
    		    system("CLS");
    		    switch(option)
    		    {
    		    	case 0:
    		    	{
    		    		return;
					}
					case 1:
					{
						printf("\n\t\t请重新输入该球员进球数:");scanf("%d",&pd[i].Goal);
						printf("\n\n\t\t更改完成!");
						system("pause");
						break;
					}
					case 2:
					{
						printf("\n\t\t请重新输入该球员总传球数:");scanf("%d",&pd[i].Allpass);
						printf("\n\n\t\t更改完成!");
						system("pause");
						break;
					}
					case 3:
					{
						for(;;)
                        {
                        	printf("\n\t\t请重新输入该球员成功传球数:");scanf("%d",&pd[i].Successpass);
                      	    system("CLS");
                        	if(&pd[i].Successpass > &pd[i].Allpass)
                     	{
	                       	printf("\n\n\t\t输入错误!请重新输入!");
	                    	system("pause");
                     	}
                    	else
						{
		                    printf("\n\n\t\t更改完成!");
	                     	system("pause");
	                     	break;
	                    }
                        }
						break;
					}
					case 4:
					{
						printf("\n\t\t请重新输入该球员犯规数:");scanf("%d",&pd[i].Foul);
						printf("\n\n\t\t更改完成!");
						system("pause");
						break;
					}
					case 5:
					{
						printf("\n\t\t请重新输入该球员黄牌数:");scanf("%d",&pd[i].YellowC);
						printf("\n\n\t\t更改完成!");
						system("pause");
						break;
					}
					case 6:
					{
						printf("\n\t\t请重新输入该球员红牌数:");scanf("%d",&pd[i].RedC);
						printf("\n\n\t\t更改完成!");
						system("pause");
						break;
					}
					case 7:
					{
						printf("\n\t\t请重新输入该球员总扑球数:");scanf("%d",&pd[i].NumSaveball);
						printf("\n\n\t\t更改完成!");
						system("pause");
						break;
					}
					case 8:
					{
						for(;;)
                        {
                        	printf("\n\n\t\t请重新输入该球员成功扑球数:");scanf("%d",&pd[i].NumSuccessSaveball);
                      	    system("CLS");
                        	if(pd[i].NumSuccessSaveball > pd[i].NumSaveball)
                     	{
	                       	printf("\n\n\t\t输入错误!请重新输入!");
	                    	system("pause");
                     	}
                    	else
						{
		                    printf("\n\n\t\t更改完成!");
	                     	system("pause");
	                     	break;
	                    }
                        }
						break;
					}
					default: continue;
				}
			}
        	break;
		}
	}
	return;
}